package com.cenxi.controller;

import com.cenxi.common.dto.LoginDTO;
import com.cenxi.common.result.Req;
import com.cenxi.common.result.Resp;
import com.cenxi.manage.ManageLoginService;
import com.cenxi.utils.subject.LoginSubject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author cenxi
 * @Date 2023/11/13 14:57
 * @Version 1.0
 */
@Api(tags = "登录接口")
@RestController
@RequestMapping("/auth")
public class LoginController {
    @Autowired
    private ManageLoginService manageLoginService;

    @PostMapping("/login")
    @ApiOperation(value = "登录")
    public Resp<LoginSubject> login(@RequestBody Req<LoginDTO> req) {
        return manageLoginService.login(req.getData());
    }

    @PostMapping("/logout")
    @ApiOperation(value = "退出")
    public Resp<Void> logout() {
        return manageLoginService.logout();
    }
}
